import request from "./request/index.js";

export async function addSupplier(data) {
    try {
        const res = await request.post("/supplier", data);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

export async function listSuppliers(data) {
    try {
        const res = await request.post("/supplier/list", data);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

export async function getSupplier(id) {
    try {
        const res = await request.get(`/supplier/${id}`);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

export async function updateSupplier(data) {
    try {
        const res = await request.put("/supplier", data);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

export async function deleteSupplier(id) {
    try {
        const res = await request.delete(`/supplier/${id}`);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}
